<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>

    <style>
        div {
            margin: 20px;

        }


        input {
            border: none;
            border: 1px solid mediumorchid;
            height: 36px;

        }

        /* 子元素获取焦点后触发 */
        div:focus-within {
            border-color: white;
            border-style: dashed;
            background: lightcoral;
            color: white;

        }
    </style>
</head>

<body>

        <div >姓名：<input type="text"></div>
        <div>年龄：<input type="text"></div>
</body>

</html>